﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CivilRegistry.ControlledModel;
using CivilRegistry.Common;

namespace CivilRegistry.UserControls
{
    public partial class UCAddress : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (SessionHandler.CurrentSession.User != null)
            {
            }

            if (!Page.IsPostBack)
            {
                ddlStateName.DataSource = State.FindAll();
                ddlStateName.DataBind();
            }
        }

        protected void ddlStateName_SelectedIndexChanged(object sender, EventArgs e)
        {
            ddlDistrictName.Items.Clear();
            ddlDistrictName.Items.Insert(0, new ListItem("--Select--", "0"));
            ddlDistrictName.DataSource = District.FindAllByStateId(Convert.ToInt32(ddlStateName.SelectedValue));
            ddlDistrictName.DataBind();
        }
    }
}